package org.study.hadoop.md.entity;

/**
 * 帖子
 */
public class Post {
	private String id;						// 帖子Id
	private int postTypeId;				// 帖子类型，1：为问题贴，2：为评论贴
	private String parentId;				// 帖子类型为2时，上一级Id
	private String acceptedAnswerId;		// 帖子类型为1时，认可的回复Id
	private String creationDate;			// 创建时间
	private String lastActivityDate;		// 最后活跃时间
	private int score;						// 分数
	private int viewCount;					// 浏览次数
	private String body;					// 主体内容
	private String ownerUserId;				// 帖子创建者
	private int commentCount;				// 帖子类型为2时，评论次数
	private String title;					// 帖子类型为1时，标题
	private String tags;					// 帖子类型为1时，标签
	private int answerCount;				// 帖子类型为1时，回复次数
	
	public Post(String id, int postTypeId, String creationDate, String lastActivityDate,
			int score, int viewCount, String ownerUserId, String body, String parentId, int commentCount) {
		this(id, postTypeId, parentId, null, creationDate, lastActivityDate, score, viewCount, body, ownerUserId, commentCount, null, null, 0);
	}
	
	public Post(String id, int postTypeId, String creationDate, String lastActivityDate,
			int score, int viewCount, String ownerUserId, String body, String acceptedAnswerId,
			String title, String tags, int answerCount) {
		this(id, postTypeId, null, acceptedAnswerId, creationDate, lastActivityDate, score, viewCount, body, ownerUserId, 0, title, tags, answerCount);
	}
	
	public Post(String id, int postTypeId, String parentId,
			String acceptedAnswerId, String creationDate,
			String lastActivityDate, int score, int viewCount, String body,
			String ownerUserId, int commentCount, String title, String tags,
			int answerCount) {
		this.id = id;
		this.postTypeId = postTypeId;
		this.parentId = parentId;
		this.acceptedAnswerId = acceptedAnswerId;
		this.creationDate = creationDate;
		this.lastActivityDate = lastActivityDate;
		this.score = score;
		this.viewCount = viewCount;
		this.body = body;
		this.ownerUserId = ownerUserId;
		this.commentCount = commentCount;
		this.title = title;
		this.tags = tags;
		this.answerCount = answerCount;
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public int getPostTypeId() {
		return postTypeId;
	}
	public void setPostTypeId(int postTypeId) {
		this.postTypeId = postTypeId;
	}
	public String getParentId() {
		return parentId;
	}
	public void setParentId(String parentId) {
		this.parentId = parentId;
	}
	public String getAcceptedAnswerId() {
		return acceptedAnswerId;
	}
	public void setAcceptedAnswerId(String acceptedAnswerId) {
		this.acceptedAnswerId = acceptedAnswerId;
	}
	public String getCreationDate() {
		return creationDate;
	}
	public void setCreationDate(String creationDate) {
		this.creationDate = creationDate;
	}
	public String getLastActivityDate() {
		return lastActivityDate;
	}
	public void setLastActivityDate(String lastActivityDate) {
		this.lastActivityDate = lastActivityDate;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public int getViewCount() {
		return viewCount;
	}
	public void setViewCount(int viewCount) {
		this.viewCount = viewCount;
	}
	public String getBody() {
		return body;
	}
	public void setBody(String body) {
		this.body = body;
	}
	public String getOwnerUserId() {
		return ownerUserId;
	}
	public void setOwnerUserId(String ownerUserId) {
		this.ownerUserId = ownerUserId;
	}
	public int getCommentCount() {
		return commentCount;
	}
	public void setCommentCount(int commentCount) {
		this.commentCount = commentCount;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getTags() {
		return tags;
	}
	public void setTags(String tags) {
		this.tags = tags;
	}
	public int getAnswerCount() {
		return answerCount;
	}
	public void setAnswerCount(int answerCount) {
		this.answerCount = answerCount;
	}
	@Override
	public String toString() {
		String base = "<row\tId=" + id + "\tPostTypeId=" + postTypeId + "\tCreationDate=" + creationDate
				+ "\tScore=" + score + "\tViewCount=" + viewCount + "\tBody=" + body + "\tOwnerUserId=" 
				+ ownerUserId + "\tLastActivityDate=" + lastActivityDate;
		if (postTypeId == 1) {
			return base + "\tAcceptedAnswerId=" + acceptedAnswerId + "\tTitle=" + title + "\tTags=" + tags
					+ "\tAnswerCount=" + answerCount + " />";
		} else {
			return base + "\tParentId=" + parentId + "\tCommentCount=" + commentCount + " />";
		}
	}
}
